/*******************************************************************************
 * FilePath    : /Software/Examples_Ble_MS1656/ble_app_peripheral_uart_simple/Src/User/User_Led.c
 * Version     : 1.0
 * Brief       : 
 * Author      : AndrewHu
 * Company     : Shanghai MacroGiga Electronics CO.,Ltd
 * Email       : Hubinbo@macrogiga.com
 * Date        : 2020-04-03 15:15:31
 * LastEditors : AndrewHu
 * LastEditTime: 2021-06-11 11:59:52
 * Description : 
 ******************************************************************************/

/* Includes ------------------------------------------------------------------*/
#include <Includes.h>
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
#define LED_RISING_FALLING_UNIT 0x04
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function ----------------------------------------------------------*/
/* extern --------------------------------------------------------------------*/

/*******************************************************************************
 * Function    : LED_ChangeStatus
 * Brief       : LED灯的亮灭状态改变
 * Parameter   : 
 * Returns     : 
 * Date        : 2020-04-04 15:18:38
 * Description : 
 ******************************************************************************/
void LED_ChangeStatus(void)
{
    if (getLedPinStatus())
        setLedPinStatus(0);
    else
        setLedPinStatus(1);
}
/*******************************************************************************
 * Function    : LED_Rising_Falling
 * Brief       : LED 呼吸灯
 * param        {*}
 * return       {*}
 * Description : 
 * Date        : 2021-06-11 11:55:30
 ******************************************************************************/
void LED_Rising_Falling(void)
{
    static u8 status = 0;
    u32 value = Tim1_CH2_GetPulse();
    if (status)
    { //渐亮
        value += LED_RISING_FALLING_UNIT;
        if (value >= 100)
        {
            status = 0;
            value = 100;
        }
        Tim1_CH2_SetPulse(value);
    }
    else
    { //渐灭
        if (value <= LED_RISING_FALLING_UNIT)
        {
            status = 1;
            value = 0;
        }
        else
        {
            value -= LED_RISING_FALLING_UNIT;
        }
        Tim1_CH2_SetPulse(value);
    }
}
